package com.yf.ability.live.service.impl;

import com.alibaba.fastjson.JSON;
import com.yf.ability.config.dto.CfgPropDTO;
import com.yf.ability.config.enums.ConfigType;
import com.yf.ability.config.enums.ProviderType;
import com.yf.ability.config.service.CfgPropService;
import com.yf.ability.live.config.CfgLiveAliyunDTO;
import com.yf.ability.live.dto.LiveBuildDTO;
import com.yf.ability.live.service.LiveBuildService;
import com.yf.ability.live.utils.AliAddrBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author bool
 */
@Service
public class LiveBuildServiceImpl implements LiveBuildService {

    @Autowired
    private CfgPropService cfgPropService;


    @Override
    public LiveBuildDTO buildLive(String id) {
        CfgPropDTO cfg = cfgPropService.detail(ConfigType.LIVE, ProviderType.ALIYUN);
        CfgLiveAliyunDTO dto = JSON.parseObject(cfg.getData(), CfgLiveAliyunDTO.class);
        return AliAddrBuilder.generate(dto, id);
    }
}
